//
//  WXMicorBlogModel.swift
//  weibo
//
//  Created by 王旭 on 16/4/20.
//  Copyright © 2016年 王旭. All rights reserved.
//

import UIKit

class WXStatusModel: NSObject {
    
    //微博id
    var id: Int64 = 0
    //微博内容
    var text : String?
    //微博发出时间
    var created_at : String?
    //微博来源
    var source : String?
    //微博作者信息
    var user : WXUserModel?
    //转发微博
    var retweeted_status: WXStatusModel?
    //配图数组
    var pic_urls: [WXHomePhotoModel]?
    
    init(dic:[String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dic)

    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            guard let dic = value as? [String:AnyObject] else{
                return
            }
            user = WXUserModel(dic: dic)
        }else if key == "retweeted_status" {
                guard let dic = value as? [String:AnyObject] else{
                    return
                }
                retweeted_status = WXStatusModel(dic: dic)
        }else if key == "pic_urls" {
            guard let dic = value as? [[String:AnyObject]] else{
                return
            }
            //
            var tempArr = [WXHomePhotoModel]()
            for pic in dic {
              let picModel = WXHomePhotoModel(dic: pic)
                tempArr.append(picModel)
            }
            pic_urls = tempArr
            
        }else{
            super.setValue(value, forKey: key)
        }
    }
    
   override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }

}
